home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / global / guys_on_tank.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  6.2 KB  |  243 lines

  1. // -----------------------------------------------------------------------
  2. //    guys_on_tank.scr
  3. //
  4. //    Use this script to make your tank have passengers...
  5. //
  6. //    (NOTE: not used yet.)
  7. //
  8. // -----------------------------------------------------------------------
  9.  
  10. // -----------------------------------------------------------------------
  11. main:
  12. // -----------------------------------------------------------------------
  13.  
  14.     end
  15.  
  16.  
  17. // -----------------------------------------------------------------------
  18. LoadPassengers local.passengers local.guy_type local.special local.passenger_name local.driver_name:
  19. //
  20. //        global/guys_on_tank.scr::LoadPassengers
  21. //
  22. // -----------------------------------------------------------------------
  23.  
  24.     if ( local.passengers <= 0 )
  25.         end
  26.  
  27.     if ( local.passengers > 5 )
  28.         local.passengers = 5
  29.  
  30.     self.passenger_count = local.passengers
  31.  
  32.     self thread TankDeathCheck
  33.  
  34.     for (local.slot = 1; local.slot <= local.passengers; local.slot++)
  35.     {
  36.         if (local.guy_type == NIL)
  37.             local.guy_type = "models/human/german_panzer_obershutze"
  38.         if (randomint (3) == 1) 
  39.             local.gun = "MP40"
  40.         else
  41.             local.gun = "Mauser KAR 98K"
  42.         if ( (local.special == "panzer") && (local.slot == 1) )
  43.             local.gun = "panzerschrek"
  44.         local.guy = spawn local.guy_type "gun" local.gun
  45.         local.guy.origin = self.origin
  46.         local.guy rendereffects "-shadow"
  47.  
  48.         self.passenger[local.slot]    = local.guy
  49.  
  50.         if ( local.passenger_name!=NIL )
  51.             local.guy.targetname = local.passenger_name
  52.  
  53.         if (level.dontdropweapons == 1)
  54.             local.guy dontdropweapons
  55.         self AttachPassengerSlot local.slot local.guy
  56. //        local.name = "passenger" + local.slot
  57. //        local.guy attach self local.name 0 ( 0 0 0 )
  58.         local.guy type_attack "cover"
  59.         local.guy leash 0
  60.         local.guy exec global/disable_ai.scr 
  61.         local.guy fixedleash 1
  62.         local.guy physics_off
  63.         local.guy.my_tank = self
  64.         local.guy.loaded = 1
  65.  
  66.     
  67.         switch (local.slot)
  68.         {
  69.         case 1:
  70.         case 2:
  71.         case 5:
  72.             local.guy exec global/setdeathanim.scr "31G302_Death"
  73.             local.guy thread BeTankGuy 31G301_German03Idle 31G503_JumpOff
  74.             break
  75.         case 3:
  76.         case 4:
  77.         default:
  78.             local.guy exec global/setdeathanim.scr "31G202_Death"
  79.             local.guy thread BeTankGuy 31G201_German02Idle 31G501_JumpOff
  80.             break
  81.         }
  82.     }
  83.  
  84.     end
  85.  
  86. // -----------------------------------------------------------------------
  87. BeTankGuy local.idle_anim local.jump_anim:
  88. // -----------------------------------------------------------------------
  89.     self.jump_anim = local.jump_anim
  90.  
  91.     self thread StopTankOnDeath
  92.     self thread StopTankOnPain
  93.  
  94.     // loop our sitting/idle animation...
  95.     self thread global/LoopAnim.Scr::LoopAnim local.idle_anim
  96.  
  97.     end
  98.  
  99. //------------------------------------------------------------------------------
  100. StopTankOnDeath:
  101. //
  102. //    If driver gets shot, we should stop the Tank...
  103. //------------------------------------------------------------------------------
  104.     self waittill death
  105.  
  106.     if ( isalive self.my_tank )
  107.     {
  108.         self.my_tank.playerlook = 0
  109.         self.my_tank thread TankStop 1
  110.     }
  111.  
  112.     End
  113.  
  114. //------------------------------------------------------------------------------
  115. StopTankOnPain:
  116. //
  117. //    If driver gets shot, we should stop the Tank...
  118. //------------------------------------------------------------------------------
  119.  
  120.     self waittill pain
  121.  
  122.     if ( self.loaded==0 )
  123.         end
  124.  
  125.     if ( isalive self )
  126.     {
  127.         self damage $world 15000 $world (0 0 0) (0 0 0) (0 0 0) 0 9 0 0
  128.         self.loaded = 0
  129.     }
  130.  
  131.     if ( isalive self.my_tank )
  132.     {
  133.         self.my_tank.playerlook = 0
  134.         self.my_tank thread TankStop 1
  135.     }
  136.     
  137.  
  138.     End
  139.  
  140. //------------------------------------------------------------------------------
  141. TankStop local.bStop:
  142. //------------------------------------------------------------------------------
  143.  
  144.     if ( self.stopped==1 )
  145.     {
  146.         End
  147.     }
  148.  
  149.     self.stopped = 1
  150.  
  151.     if ( local.bStop )
  152.     {
  153.         self stop
  154.     }
  155.  
  156.     // give time for tank to stop...
  157.     wait 1.5
  158.  
  159.     self thread UnloadPassengers 1
  160.  
  161.     End
  162.  
  163. // -----------------------------------------------------------------------
  164. UnloadPassengers local.go_after_player:
  165. // -----------------------------------------------------------------------
  166.  
  167.     for (local.slot = 0; local.slot <= 5; local.slot++)
  168.     {
  169.         self thread tank_passenger_unload local.slot local.go_after_player
  170.     }
  171.  
  172.     end
  173.  
  174.         
  175. // -----------------------------------------------------------------------
  176. tank_passenger_unload local.slot local.go_after_player:
  177. // -----------------------------------------------------------------------
  178.     local.ent = self QueryPassengerSlotEntity local.slot
  179.  
  180.     if (local.ent == NULL)
  181.         end
  182.     
  183.     if (isAlive local.ent && local.ent.loaded==1)
  184.     {
  185.         local.ent thread global/LoopAnim.Scr::LoopAnimStop
  186.         local.ent.loaded = 0
  187.         local.ent exec global/disable_ai.scr
  188.         self DetachPassengerSlot local.slot local.ent.origin
  189.         local.tag = ("passenger" + local.slot)
  190.         local.ent.origin = self gettagposition local.tag
  191.         local.ent.angles = self gettagangles local.tag
  192.         local.ent notsolid
  193.         local.ent physics_on
  194.         local.ent anim_noclip local.ent.jump_anim
  195.         local.ent waittill animdone
  196.         local.ent solid
  197.         local.ent rendereffects "+shadow"
  198.         local.ent leash 10000
  199.         local.ent exec global/setdeathanim.scr NIL
  200.         local.ent exec global/enable_ai.scr
  201.  
  202.         if ( local.go_after_player!=NIL && local.go_after_player==1 )
  203.         {
  204.             local.ent runto $player
  205.             local.ent attackplayer
  206.         }
  207.     }
  208.  
  209.     end
  210.  
  211. // -----------------------------------------------------------------------
  212. DeletePassengers:
  213. // used by 1-1
  214. // -----------------------------------------------------------------------
  215.  
  216.     for (local.slot = 0; local.slot <= self.passenger_count; local.slot++)
  217.     {
  218.         if ( self.passenger[local.slot]!=NIL )
  219.             self.passenger[local.slot] delete
  220.  
  221.     }
  222.  
  223.     end
  224.  
  225. // -----------------------------------------------------------------------
  226. TankDeathCheck:
  227. //
  228. //    if tank dies, kill anyone who hasn't unloaded..
  229. // -----------------------------------------------------------------------
  230.     self waittill death
  231.  
  232.     for (local.slot = 0; local.slot <= self.passenger_count; local.slot++)
  233.     {
  234.         if ( self.passenger[local.slot]!=NIL )
  235.         {
  236.             if ( self.passenger[local.slot].loaded==1 )
  237.                 self.passenger[local.slot] damage self 9000 self (0 0 0) (0 0 0) (0 0 0) 0 9 0 0
  238.         }
  239.  
  240.     }
  241.  
  242.     end
  243.